from tortoise import models, fields


class Category(models.Model):
    """商品分类表"""
    id = fields.IntField(pk=True, description="主键id")
    name = fields.CharField(max_length=50, description="分类名称")
    parent_id = fields.IntField(null=True, description="父级分类id")
    is_active = fields.BooleanField(default=True, description="是否激活")
    category_level = fields.IntField(description="分类层级")
    category_rank = fields.IntField(description="分类排序")
    created_time = fields.DatetimeField(auto_now_add=True, description="创建时间")
    updated_time = fields.DatetimeField(auto_now=True, description="更新时间")
    created_user = fields.CharField(max_length=50, description="创建用户")
    updated_user = fields.CharField(max_length=50, description="更新用户")

    class Meta:
        table = "tb_mall_category"
        table_description = "商城分类表"

    def __repr__(self):
        return f"<Category(id={self.id}, name={self.name})>"

    __str__ = __repr__